package com.admission.web.admin;

import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import com.admission.model.CollegeNotice;
import com.admission.service.CollegeNoticeManager;
import com.admission.web.CrudActionSupport;
@Namespace("/admin")
public class CollegeNoticeAdminAction extends CrudActionSupport<CollegeNotice>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String value;
	private CollegeNotice entity;
	private CollegeNoticeManager collegeNoticeManager;

	public CollegeNotice getModel() {
		return entity;
	}

	@Override
	public String list() throws Exception {
		return null;
	}

	@Override
	public String input() throws Exception {
		
		return INPUT;
	}

	@Override
	public String save() throws Exception {
		try{
			collegeNoticeManager.save(entity);
			 this.addActionMessage("操作成功");
		} catch (Exception e) {
		   this.addActionMessage("操作失败，请重新操作");
	    }
			return INPUT;
	}

	@Override
	public String delete() throws Exception {
		return null;
	}

	@Override
	protected void prepareModel() throws Exception {
		if(collegeNoticeManager.getByType(value)==null)
			entity=new CollegeNotice();
		else
			entity=collegeNoticeManager.getByType(value);
		
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public CollegeNotice getEntity() {
		return entity;
	}

	public void setEntity(CollegeNotice entity) {
		this.entity = entity;
	}

	public CollegeNoticeManager getCollegeNoticeManager() {
		return collegeNoticeManager;
	}
	@Autowired
	public void setCollegeNoticeManager(CollegeNoticeManager collegeNoticeManager) {
		this.collegeNoticeManager = collegeNoticeManager;
	}

}
